package lxs.swift.fn;

import lxs.swift.operation.Try;
import org.jetbrains.annotations.NotNull;

import java.util.function.Supplier;

public interface Supply<T, E extends Throwable> extends Fn<Supplier<T>> {
    T get() throws E;

    @Override
    default Supplier<T> std() {
        return () -> Try.valueOf(this).ret();
    }

    static <T, E extends Throwable> Supply<T, E> panic(@NotNull E error) {
        return () -> {
            throw error;
        };
    }
}
